# -*- mode: python ; coding: utf-8 -*-

import os
import sys
import certifi

# 统一打包路径
project_dir = os.getcwd()
pathex = [project_dir]

# 动态构建数据文件列表
datas = [
    ('icon.ico', '.'),
    ('default_todo_data.db', '.'),
    ('plugin_config.json', '.'),
    ('updater_plugin.py', '.'),
    (os.path.join(sys.base_prefix, 'python3.dll'), '.'),  # 添加Python DLL
]

# icons文件夹不再需要，SVG图标已嵌入到代码中

# 打包 certifi 证书
try:
    cacert = certifi.where().replace('\\\\', '/')
    datas.append((cacert, 'certifi'))
except Exception:
    pass

a = Analysis(
    ['main.py'],
    pathex=pathex,
    binaries=[],
    datas=datas,
    hiddenimports=[
        'urllib.request',
        'urllib.error',
        'json',
        'subprocess',
        'sqlite3',
        'PyQt5.QtCore',
        'PyQt5.QtWidgets',
        'PyQt5.QtGui',
        'requests',
        'webdav_sync',
        'search_plugin',
        'login',
    ],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],  # 移除不存在的hook
    excludes=[
        'tkinter',
        'matplotlib',
        'numpy',
        'pandas',
    ],
    noarchive=False,
    optimize=0,
)
pyz = PYZ(a.pure)

exe = EXE(
    pyz,
    a.scripts,
    a.binaries,
    a.datas,
    [],
    name='main',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=False,  # 禁用UPX压缩
    console=False,  # 正式发布隐藏控制台
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
    icon='icon.ico',
    version_file='version_info.py',
    manifest=None,
)